package com.avoid.easymqtt.mqtt.common;

import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

/**
 * 描述
 *
 * @author avoid@fiture.com
 * @date 2022/5/11
 * @motto Life is so short,do something to make yourself happy,such as coding
 */
public class MqttNettyUtils {

    private static final String ATTR_CLIENTID = "ClientID";
    private static final AttributeKey<Object> ATTR_KEY_CLIENTID = AttributeKey.valueOf(ATTR_CLIENTID);

    public static void clientID(Channel channel, String clientID) {
        channel.attr(ATTR_KEY_CLIENTID).set(clientID);
    }

    public static String clientID(Channel channel) {
        return (String) channel.attr(ATTR_KEY_CLIENTID).get();
    }
}
